package com.donfu.web.controller.house;

import java.util.List;

import com.donfu.system.domain.house.HouseGoodsSku;
import com.donfu.system.service.house.IHouseGoodsSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.donfu.common.annotation.Log;
import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.common.enums.BusinessType;
import com.donfu.common.utils.poi.ExcelUtil;
import com.donfu.common.core.page.TableDataInfo;

/**
 * 商品sku(存具体的商品)Controller
 * 
 * @author donfu
 * @date 2021-12-06
 */
@Api(tags = "后台--商品sku(存具体的商品)")
@RestController
@RequestMapping("/system/sku")
public class HouseGoodsSkuController extends BaseController
{
    @Autowired
    private IHouseGoodsSkuService houseGoodsSkuService;

    /**
     * 查询商品sku(存具体的商品)列表
     */
    @ApiOperation("查询商品sku(存具体的商品)列表")
    @PreAuthorize("@ss.hasPermi('system:sku:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseGoodsSku houseGoodsSku)
    {
        startPage();
        List<HouseGoodsSku> list = houseGoodsSkuService.selectHouseGoodsSkuList(houseGoodsSku);
        return getDataTable(list);
    }

    /**
     * 导出商品sku(存具体的商品)列表
     */
    @ApiOperation("导出商品sku(存具体的商品)列表")
    @PreAuthorize("@ss.hasPermi('system:sku:export')")
    @Log(title = "商品sku(存具体的商品)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HouseGoodsSku houseGoodsSku)
    {
        List<HouseGoodsSku> list = houseGoodsSkuService.selectHouseGoodsSkuList(houseGoodsSku);
        ExcelUtil<HouseGoodsSku> util = new ExcelUtil<HouseGoodsSku>(HouseGoodsSku.class);
        return util.exportExcel(list, "商品sku(存具体的商品)数据");
    }

    /**
     * 获取商品sku(存具体的商品)详细信息
     */
    @ApiOperation("获取商品sku(存具体的商品)详细信息")
    @ApiImplicitParam(name = "id", value = "商品skuId", dataType = "Long", required = true)
    @PreAuthorize("@ss.hasPermi('system:sku:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(houseGoodsSkuService.selectHouseGoodsSkuById(id));
    }

    /**
     * 新增商品sku(存具体的商品)
     */
    @ApiOperation("新增")
    @PreAuthorize("@ss.hasPermi('system:sku:add')")
    @Log(title = "商品sku(存具体的商品)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseGoodsSku houseGoodsSku)
    {
        return toAjax(houseGoodsSkuService.insertHouseGoodsSku(houseGoodsSku));
    }

    /**
     * 修改商品sku(存具体的商品)
     */
    @ApiOperation("修改")
    @PreAuthorize("@ss.hasPermi('system:sku:edit')")
    @Log(title = "商品sku(存具体的商品)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseGoodsSku houseGoodsSku)
    {
        return toAjax(houseGoodsSkuService.updateHouseGoodsSku(houseGoodsSku));
    }

    /**
     * 删除商品sku(存具体的商品)
     */
    @ApiOperation("删除")
    @ApiImplicitParam(name = "ids", value = "商品skuId集合", dataType = "Long", required = true)
    @PreAuthorize("@ss.hasPermi('system:sku:remove')")
    @Log(title = "商品sku(存具体的商品)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseGoodsSkuService.deleteHouseGoodsSkuByIds(ids));
    }
}
